package com.homework.module9part1.service.impl;

import com.homework.dao.domain.Student;
import com.homework.dao.mapper.StudentMapper;
import com.homework.module9part1.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    protected StudentMapper studentMapper;

    public boolean addStudent(Student student) {
        if(student == null) {
            return false;
        }

        return studentMapper.addStudent(student);
    }

    public boolean delStudent(int id) {
        if(id <= 0) {
            return false;
        }
        return studentMapper.delStudent(id);
    }

    public boolean modifyStudent(Student student) {
        if(student == null || student.getId() == 0) {
            return false;
        }
        return studentMapper.modifyStudent(student);
    }

    public List<Student> findStudentByName(String name) {
        return studentMapper.findStudentByName(name);
    }

    public List<Student> findAll() {
        return studentMapper.findAll();
    }
}
